﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class BuyYourself : System.Web.UI.Page
{
    public string time;
    protected List<Model.Lottery> arlist = null;
    protected DataTable Datacq = null;
    protected DataTable Dataallje = null;
    protected DataTable Dataallzgje = null;
    public string cptype = "";
    public Int64 jine;
    public Int64 a;
    public Int64 b;
    public Int64 c;
    public string yi;
    public string wan;
    public string yuan;
    protected string css = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        cptype = Request["t"];
        DataCentercq();
       time = DateTime.Now.ToString("yyyy-MM-dd");
        alljine();
    }
    
    protected void qsddl_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }

    private void DataCentercq()//双色球-hemai
    {

        string sqlstr = @" select  CMember.nickname,LotteryAnnouncement.openTime ,[LotteryBuyDetail].[LotteryQS],[dbo].[LotteryBuyDetail].WinMoney,
                         [LotteryBuyDetail].LotteryMoney  
                         from [LotteryBuyDetail],LotteryAnnouncement,CMember  where  
                         [LotteryBuyDetail].LotteryQs=[dbo].[LotteryAnnouncement].LotteryQS   and 
                         [LotteryBuyDetail].User_id=CMember.Id  and [LotteryBuyDetail].LotteryType=" + cptype + " and IsWin=1 ORDER BY [LotteryQS] DESC ";

        Datacq = BLL.LotteryChippedUser.GetPageListBysql(sqlstr);



    }
    protected void qsSelectedIndexChanged(object sender, EventArgs e)
    {

        if (qsDropDownList.SelectedValue == "1")
        {
            Response.Redirect("DataCenterDetail.aspx?t=1");

        }
        if (qsDropDownList.SelectedValue == "2")
        {
            Response.Redirect("DataCenterDetail.aspx?t=2");

        }
        if (qsDropDownList.SelectedValue == "3")
        {
            Response.Redirect("DataCenterDetail.aspx?t=3");

        }
        if (qsDropDownList.SelectedValue == "4")
        {
            Response.Redirect("DataCenterDetail.aspx?t=4");

        }
        if (qsDropDownList.SelectedValue == "5")
        {
            Response.Redirect("DataCenterDetail.aspx?t=5");

        }
        if (qsDropDownList.SelectedValue == "6")
        {
            Response.Redirect("DataCenterDetail.aspx?t=6");

        }
        if (qsDropDownList.SelectedValue == "7")
        {
            Response.Redirect("DataCenterDetail.aspx?t=7");

        }

    }

    private void alljine()//双色球
    {
        string sql = " select  LotteryChipped.LotteryOpenTime, isnull(sum(LotteryChipped.WinMoney),0)  as alljine from LotteryChipped  where LotteryChipped.LotteryType=" + cptype + "  group by  LotteryChipped.LotteryOpenTime order by LotteryOpenTime desc ";
        Dataallje = BLL.LotteryChipped.GetPageListBysql(sql);
        string sqll = "select LotteryBuyDetail.LotteryQs,isnull(sum([LotteryBuyDetail].WinMoney),0)  as alljine from [LotteryBuyDetail]  where LotteryBuyDetail.LotteryType=" + cptype + "   group by  LotteryBuyDetail.LotteryQs order by LotteryQs  desc";
        Dataallzgje = BLL.LotteryBuyDetail.GetPageListBysql(sqll);

        if (Dataallje.Rows.Count > 0)
        {
            jine = Convert.ToInt64(Dataallje.Rows[0]["alljine"]) + Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }
        else
        {
            jine = Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }

        if (jine > 99999999)
        {

            a = Convert.ToInt64(jine) / 100000000;
            yi = a + "亿";
            jine = jine - a * 100000000;
        }
        if (jine > 9999)
        {
            b = Convert.ToInt64(jine) / 10000;
            wan = b + "万";
            jine = jine - b * 10000;
        }
        if (jine < 10000)
        {

            c = Convert.ToInt64(jine);
            if (c < 1000)
            {
                yuan = "0" + c + "元";
            }
            if (c == 0)
            {
                yuan = null;
            }
            else
            {
                yuan = c + "元";

            }

        }

    }


}

